<?php


namespace app\api\business;

use app\common\lib\Show;
use app\common\model\NewsModel;
use think\Exception;

class NewsList
{
    protected $news = null;

    public function __construct()
    {
        $this->news = new NewsModel();
    }

    /**
     * @return NewsModel
     */
    public function getNews($channelId, $limit)
    {
        try {
            $res = $this->news->getNewsList($channelId, $limit);
        }catch (Exception $e){
            return Show::error('数据获取失败');
        }
        if (empty($res)){
            return [];
        }
        // 将分页信息添加到res数组
//        $total = $res->total();
        $result = $res->toArray();
        return $result;
    }
}
